home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Financial / Stopwatch2.3 / Source / ExpenseViewMgr.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  93 lines

  1. /*
  2.  * For legal stuff see the file COPYRIGHT
  3.  */
  4. #import "ExpenseViewMgr.h"
  5. #import "ClientInspector.h"
  6. #import "ExpenseEditor.h"
  7. #import "Controller.h"
  8.  
  9. @interface ExpenseViewMgr(PRIVATE)
  10. - (void)displayTotalExpenses;
  11. - (void)displayClientExpenses;
  12. - (float)totalExpenses;
  13. @end
  14.  
  15.  
  16. @implementation ExpenseViewMgr
  17.  
  18. - itemEditor
  19. {
  20.   return [ExpenseEditor new];
  21. }
  22.  
  23. /*
  24.  * Provide the add, delete and sort methods to invoke on ClientInfo objects
  25.  */
  26. - (SEL)addMethod
  27. {
  28.   return @selector(addExpense:);
  29. }
  30.  
  31. - (SEL)deleteMethod
  32. {
  33.   return @selector(deleteExpense:);
  34. }
  35.  
  36. - (SEL)sortMethod
  37. {
  38.   return @selector(sortExpenses);
  39. }
  40.  
  41. - info:(ClientInfo *)info itemAt:(int)position
  42. {
  43.   return [info expenseAt:position];
  44. }
  45.  
  46. - (int)itemCount:(ClientInfo *)info 
  47. {
  48.   return [info expenseCount];
  49. }
  50.  
  51. - (void)displaySummary
  52. {
  53.   [self displayClientExpenses];
  54.   [self displayTotalExpenses];
  55. }
  56.  
  57. @implementation ExpenseViewMgr(PRIVATE)
  58.  
  59. - (float)totalExpenses
  60. {
  61.   List *clientList = [[NXApp delegate] clientList];
  62.   int i, count = [clientList count];
  63.   float totalExp = 0.0;
  64.  
  65.   for ( i = 0; i < count; i++ )
  66.     totalExp += [[clientList objectAt:i] totalExpenses];
  67.  
  68.   return totalExp;
  69. }
  70.  
  71. - (void)displayClientExpenses
  72. {
  73.   char buf[20];
  74.   id info = [[ClientInspector sharedInstance] selectedClient];
  75.  
  76.   if ( info ) {
  77.     sprintf( buf, "%.2f", [info totalExpenses] );
  78.     [clientExpensesField setStringValue:buf];
  79.   } else
  80.     [clientExpensesField setStringValue:""];
  81. }
  82.  
  83. - (void)displayTotalExpenses
  84. {
  85.   char buf[20];
  86.  
  87.   sprintf( buf, "%.2f", [self totalExpenses] );
  88.   [totalExpensesField setStringValue:buf];
  89. }
  90.  
  91. @end
  92.  
  93.